package com.zero.lite.dao.utils;





import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by zengzr on 2018/5/5.
 * 字典转换工具
 */
public class VoUtil {

    public static Map<String,Object> toVo(BaseVo vo,Object entity){
        if (entity==null) return null;
        Map<String,Object> rs=new HashMap<>();
        Field[] declaredFields = entity.getClass().getDeclaredFields();
        for(Field field:declaredFields){
            field.setAccessible(true);
            Object value = null;
            try {
                value = field.get(entity);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            rs.put(field.getName(), value);
        }

        return rs;
    }
}
